%% Adding footnotes in the report
% by Jaromir Benes
%
% This m-file show how to use the option 'footnote=' to add footnotes to
% some of the report elements.

%% Clear Workspace

clear;
close all;
home;
irisrequired 20111205;

%% Start new report

x = report.new();

%% Table with footnotes
%
% You can place footnotes at the table title, and at the individual
% entries. 

x.table('Table','range=',1:10,'footnote=','Table footnote...');

    x.series('First series',tseries(1:10,@rand),'footnote=','Series footnote...');
    x.series('Second series',tseries(1:10,@rand));

x.pagebreak();

%% (La)TeX block of code with footnotes

x.tex('My equation','$\alpha$','footnote=','Tex footnote...');

%% Some report elements cannot have footnotes
%
% For example, sections do not show any footnotes; this is a limitation
% caused unfortunately by how LaTeX works.

x.section('Section','footnote=','Section footnote...');

x.pagebreak();

%% Table footnotes do not show if the table title is empty
%
% Footnotes are not created if they are added to a top-level object (such
% as a table, matrix, array, figure, tex) with an empty caption (i.e. the
% text string used for the element's title). If you do want to force the
% footnote, you can enter a caption with a blank space, |' '|.

x.table('','range=',1:10,'footnote=','No footnote for tables with empty caption...');

    x.series('First series',tseries(1:10,@rand),'footnote=','Series footnote...');
    x.subheading('Subheading...','footnote=','Subheading footnote...');
    x.series('Second series',tseries(1:10,@rand));
    
x.table(' ','range=',qq(2010,1):qq(2011,4), ...
    'dateFormat=','YYYY:P', ...
    'colWidth=',3.5, ...
    'headlineJust=','r', ...
    'colFootnote=',{qq(2011,4),'Preliminary estimate...'}, ...
    'footnote=','The footnote appears if the caption (and hence the title) is non-empty -- even though it''s only a blank space...');

    x.series('First series',tseries(qq(2010,1):qq(2011,4),@rand),'footnote=','Series footnote...');
    x.subheading('Subheading...','footnote=','Subheading footnote...');
    x.series('Second series',tseries(qq(2010,1):qq(2011,4),@rand));

%% Publish report to PDF
    
x.publish('report_footnotes.pdf');

open report_footnotes.pdf;

%% Help on IRIS functions used in this m-file
%
% Use either `help` to display help in the command window, or `idoc`
% to display help in an HTML browser window.
%
%    help report
%    help report/new
%    help report/table
%    help report/series
%    help report/pagebreak
%    help report/section
%    help report/subheading
%    help report/publish
%    help tseries
%    help tseries/tseries
